﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8" />
    <title>方向条件-按照岗位计算</title>
    <link href="../../Scripts/easyUI145/themes/color.css" rel="stylesheet" />
    <link href="../../Scripts/easyUI145/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../../Scripts/EasyUIUtility.js" type="text/javascript"></script>

    <link href="../../Scripts/easyUI145/themes/icon.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="../../Scripts/easyUI/jquery.easyui.min.js" type="text/javascript"></script>

    <link href="../../Style/skin/css/Default.css" rel="stylesheet" />
    <link href="../../Style/skin/adminfont/iconfont.css" rel="stylesheet" />
    <link href="../../Scripts/bootstrap/css/bootstrap.min.css" rel="stylesheet" />

    <!-- 引用通用的js文件. -->
    <script src="../../Scripts/config.js" type="text/javascript"></script>
    <script src="../../Comm/Gener.js" type="text/javascript"></script>
    <script src="../../Comm/JScript.js" type="text/javascript"></script>
    <script src="../CCFlowEnum.js" type="text/javascript"></script>

    <script src="../Admin.js"></script>

    <script type="text/javascript" language="javascript">

        var operatorValue = "";
        var operatorValueT = "";

        //页面启动函数.
        $(function () {

            debugger;

            $("#Msg").html("正在加载,请稍后......");
            var ifm = document.getElementById("stationFrame");
            ifm.height = document.documentElement.clientHeight - 67;

          
            var mypk = GetQueryString("MyPK");
            var cond = new Entity("BP.WF.Template.Cond");
            cond.MyPK = mypk;
            if (mypk != null) {
                cond.SetPKVal(mypk);
                cond.RetrieveFromDBSources();
            }

            // 运算的值 Stations.
            var operatorValue = cond.OperatorValue.replace(/,/g, "@");
            //获取已指定操作员的岗位条件
            operatorValues = operatorValue.split("@");

            //标签
            var operatorValueTs = cond.OperatorValueT.replace(/&nbsp;&nbsp;/g,",");

            /*设置值.*/
            document.getElementById("Stations").innerHTML = operatorValue.replace(/@/g, ",");
            var len = operatorValue==""?0: operatorValues.length > 0 ? operatorValues.length - 2 : 0;
            document.getElementById("StationNames").innerHTML = "合计:(<font color=red>" + len + "</font>)条" + operatorValueTs;
            document.getElementById("StationTs").innerHTML = operatorValueTs;
            $("#Msg").html("");
        });

        function OpenStations(selectType) {

            var stas = $("#Stations").html();

            var url = "SelectStation.htm?FK_Node=" + GetQueryString("FK_Node") + "&Stas=" + stas + "&SelectType=" + selectType;
            document.getElementById("stationFrame").style.width = "100%";
            document.getElementById("stationFrame").src = url;
            $("#win").window("open");
        }


        function Save() {

            //var checkBoxIDs = GenerCheckIDs(); //获得所有的 checkBox ID传入到后台去,用于解决checkbox控件，在没有被选择的时候，没有值的问题。
            //获取所有选中的checkbox.
            var stas = document.getElementById("Stations").innerHTML;
            var staNames = document.getElementById("StationTs").innerText;

            var handler = new HttpHandler("BP.WF.HttpHandler.WF_Admin_Cond");
            handler.AddPara("FK_Node", GetQueryString("FK_Node"));
            handler.AddPara("Stations", stas);
            handler.AddPara("StationNames", staNames);
            handler.AddFormData()
            handler.AddUrlData();
            var data = handler.DoMethodReturnString("CondByStation_Save");
            alert("保存成功");
            Back();
        }


        function getChidrenValue(data) {

            $('#win').window('close'); // close a window
            // if (data[3] == "1") {

            document.getElementById("StationNames").innerHTML = "合计:(<font color=red>" + data[2] + "</font>)条" + data[1];
            document.getElementById("Stations").innerHTML = data[0];
            document.getElementById("StationTs").innerHTML = data[1];
            return;
            //}


            if (data[3] == "2") {
                $("#groupStas").html(data[0]);
                $("#groupStations").html(data[1]);
                $("#groupCount").html(data[2]);

                var orgCount = $("#orgCount").html();
                var orgStations = $("#orgStations").html();
                var orgStas = $("#orgStas").html();
                var count = 0;
                if (orgCount == null || orgCount == "") orgCount = 0;
                if (data[2] == null || data[2] == "") data[2] = 0;
                count = parseInt(orgCount) + parseInt(data[2]);
                document.getElementById("stations").innerHTML = "合计:(<font color=red>" + count + "</font>)条" + orgStations + data[1];
                document.getElementById("Stas").innerHTML = orgStas + data[0];
            }

            if (data[3] == "3") {
                $("#orgStas").html(data[0]);
                $("#orgStations").html(data[1]);
                $("#orgCount").html(data[2]);
                var groupCount = $("#groupCount").html();
                var groupStations = $("#groupStations").html();
                var groupStas = $("#groupStas").html();
                var count = 0;

                if (groupCount == null || groupCount == "")
                    groupCount = 0;

                if (data[2] == null || data[2] == "")
                    data[2] = 0;

                count = parseInt(groupCount) + parseInt(data[2]);
                document.getElementById("stations").innerHTML = "合计:(<font color=red>" + count + "</font>)条" + groupStations + data[1];
                document.getElementById("Stas").innerHTML = groupStas + data[0];
            }

        }


        //返回.
        function Back() {
            var url = GetHrefUrl();
            if (GetQueryString("CondOrAnd") == null)
                url = url.replace('CondStation.htm', 'List.htm');
            else {
                url = url.replace('CondStation.htm', 'DirList.htm');
                url = url.replace('&CondOrAnd=' + GetQueryString("CondOrAnd"), '  ');
            }
            if (url.indexOf("MyPK=") != -1) {
                url = url.replace("&MyPK=" +GetQueryString("MyPK"), "");
            }
            SetHref(url);
        }
    </script>

    <style type="text/css">
        ul .cond li {
            display: none;
            line-height: 50px;
        }

            ul .cond li .active {
                display: block;
            }

        select {
            display: inline-block;
            width: 200px;
        }


        .lbls span {
            width: 80px;
        }
    </style>
</head>
<body>
    <div class="container-full">
        <div class="attrnode-bar-header">
            <span class="pull-right">
                <button id="Btn_Save" name="Btn_Save" onclick="Save();">保存</button>
                <button id="Btn_Back" name="Btn_Back" onclick="Back();">返回</button>
            </span>

        </div>
        <form id="cc">


            <fieldset id="AdminModel">
                <legend>设置</legend>
                <ul>
                    <li>以岗位做为条件. </li>
                    <li> <a href="javascript:OpenStations()">设置岗位</a> </li>

                    <li>已经设置的岗位. </li>

                    <li><div id="StationNames"> </div></li>
                    <li style="display:none"><div id="StationTs"> </div></li>
                    <li style="display:none"><div id="Stations"> </div></li>
                </ul>


                <legend>高级选项</legend>
                <div class="pd15">
                    指定的操作员：<select id="DDL_SpecOperWay" name="DDL_SpecOperWay" onchange="selChange()">
                        <option selected="selected" value="0">当前操作员</option>
                        <option value="1">指定节点的操作员</option>
                        <option value="2">指定表单字段作为操作员</option>
                        <option value="3">指定操作员编号</option>
                    </select>
                    <input type="hidden" name="initDDL_SpecOperWay" id="initDDL_SpecOperWay" value=" " />
                    <input type="hidden" name="initTB_SpecOperPara" id="initTB_SpecOperPara" value=" " />
                    <br />
                    <br />
                    <span class="lbls">
                        <span id="span0">参数：</span>
                        <span id="span1" style="display: none">节点编号：</span>
                        <span id="span2" style="display: none">表单字段：</span>
                        <span id="span3" style="display: none">操作员编号：</span>
                    </span>
                    <input id="TB_SpecOperPara" name="TB_SpecOperPara" type="text"  style="width: 200px;" />&nbsp;&nbsp;多个值请用英文“逗号”来分隔。
                </div>
                </ul>
                </ul>
            </fieldset>

            <!--隐藏的文本框-->
            <div id="win" class="easyui-window" title="绑定岗位" style="width:600px;height:400px" closed="true"
                 data-options="iconCls:'icon-save',modal:true">

                <div data-options="region:'north',title:'North Title',split:true" style="height:50px;">
                    <iframe id="stationFrame" src="#" scrolling="no" frameborder="0"></iframe>

                </div>
            </div>

        </form>
    </div>
</body>
</html>
